#装饰器带类参数
class locker:
    def __init__(self):
        print("locker.__init__() should be not called.")


    @staticmethod
    def acquire():#加锁
        print("locker.acquire() called(这是静态方法)")

    @staticmethod
    def release():#解锁
        print("locker.release() called.(不需要对象实例)")

def deco(cls):
    '''cls必现实现acquire和Release静态方法'''
    def _deco(func):
        def __deco():
            print("before %s called [%s]." % (func.__name__,cls))
            cls.acquire()#调用了类的加锁方法
            try:
                return func()
            finally:
                cls.release()#调用了一个类的解锁方法
        return __deco
    return _deco

@deco(locker) #类的对象
def myfunc():
    print("myfunc() called.")

myfunc()